-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[libc++] Remove a bunch of forward declarations from __tree and simplify __is_tree_value_type #152451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cab85b2
to
52fe3cc
Compare
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/152451.diff 2 Files Affected:
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 3dd5ae585e1db..6dadd0915c984 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -27,15 +27,13 @@
#include <__type_traits/copy_cvref.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/invoke.h>
-#include <__type_traits/is_const.h>
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_nothrow_assignable.h>
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/is_same.h>
+#include <__type_traits/is_specialization.h>
#include <__type_traits/is_swappable.h>
#include <__type_traits/remove_const.h>
-#include <__type_traits/remove_const_ref.h>
-#include <__type_traits/remove_cvref.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/pair.h>
@@ -51,13 +49,6 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Tp, class _Compare, class _Allocator>
-class __tree;
-template <class _Tp, class _NodePtr, class _DiffType>
-class __tree_iterator;
-template <class _Tp, class _ConstNodePtr, class _DiffType>
-class __tree_const_iterator;
-
template <class _Pointer>
class __tree_end_node;
template <class _VoidPtr>
@@ -68,13 +59,6 @@ class __tree_node;
template <class _Key, class _Value>
struct __value_type;
-template <class _Allocator>
-class __map_node_destructor;
-template <class _TreeIterator>
-class __map_iterator;
-template <class _TreeIterator>
-class __map_const_iterator;
-
/*
_NodePtr algorithms
@@ -492,16 +476,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEP
// node traits
template <class _Tp>
-struct __is_tree_value_type_imp : false_type {};
-
-template <class _Key, class _Value>
-struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {};
-
-template <class... _Args>
-struct __is_tree_value_type : false_type {};
-
-template <class _One>
-struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {};
+inline const bool __is_tree_value_type_v = __is_specialization_v<_Tp, __value_type>;
template <class _Tp>
struct __get_tree_key_type {
@@ -974,23 +949,23 @@ public:
return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first;
}
- template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
+ template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
_LIBCPP_HIDE_FROM_ABI void
__insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) {
__emplace_hint_unique(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
}
- template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
+ template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
_LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(const_iterator __p, _Tp&& __value) {
__emplace_hint_unique(__p, std::move(__value));
}
- template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
+ template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
_LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, value_type&& __value) {
__emplace_hint_multi(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
}
- template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
+ template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
_LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, _Tp&& __value) {
__emplace_hint_multi(__p, std::move(__value));
}
@@ -1137,7 +1112,7 @@ private:
}
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
- template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
+ template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
_LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
using __key_type = __remove_const_t<typename value_type::first_type>;
@@ -1147,7 +1122,7 @@ private:
__lhs.second = std::forward<_From>(__rhs).second;
}
- template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
+ template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
_LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) {
__lhs = std::forward<_From>(__rhs);
}
diff --git a/libcxx/include/__type_traits/is_specialization.h b/libcxx/include/__type_traits/is_specialization.h
index 9b75636b1a511..f14ab93c3c7dc 100644
--- a/libcxx/include/__type_traits/is_specialization.h
+++ b/libcxx/include/__type_traits/is_specialization.h
@@ -30,15 +30,11 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 17
-
template <class _Tp, template <class...> class _Template>
-inline constexpr bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template
+inline const bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template
template <template <class...> class _Template, class... _Args>
-inline constexpr bool __is_specialization_v<_Template<_Args...>, _Template> = true;
-
-#endif // _LIBCPP_STD_VER >= 17
+inline const bool __is_specialization_v<_Template<_Args...>, _Template> = true;
_LIBCPP_END_NAMESPACE_STD
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.